# encoding: utf-8
""" 
@version: v1.0 
@author: autumner 
@license: Apache Licence  
@contact: 18322313385@163.com 
@site:  https://gitee.com/autumner/pythoncookbook
@software: PyCharm 
@file: net_ssl_2_flask_server.py 
@time: 2019/7/17 上午10:33
"""
'''
双向认证服务端
'''

from flask import Flask
import ssl


app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

if __name__ == '__main__':
    CA_FILE = "client_cert.pem"
    KEY_FILE = "server_key.pem"
    CERT_FILE = "server_cert.pem"

    context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
    context.load_cert_chain(certfile=CERT_FILE, keyfile=KEY_FILE)
    context.load_verify_locations(CA_FILE)
    context.verify_mode = ssl.CERT_REQUIRED
    app.run(debug=True, ssl_context=context)

